//
// Created by Administrator on 2020/12/18 0018.
//

#include "InstanceFieldAccess.h"
#include <jni.h>
#include <stdio.h>

JNIEXPORT void  JNICALL  Java_com_yangyongfeng_JNI_1library_InstanceFieldAccess_accessField(JNIEnv *env, jobject obj)
{
    jfieldID  fid;
    jstring  jstr;
    const char *str;
    jchar c;

    jclass  cls = (*env).GetObjectClass(obj);
    if (cls == NULL){
        return;;
    }
    printf("In c:\n");

    /*look for the instance field s in cls*/
    fid = (*env).GetFieldID(cls,"type","C");
    if (fid == NULL)
    {
        return;
    }

    /*Read the instance field s*/
    c = (*env).GetCharField(obj,fid);
    printf("c.c= \"%d\"\n",c);
    c = 'N';
    (*env).SetCharField(obj,fid,c);

}